#!/bin/bash

GPF_FILENAME=reservewords.gpf
KEYWORDS_FILENAME=keywords
HEADER_FILENAME=reservewords.h

echo -e "struct Keyword { const char *name; int value; };\n%%" >$GPF_FILENAME

# 根据小写的关键写列表，生成对应的宏，GPF项
SEQ=300
for WORD in `cat $KEYWORDS_FILENAME`
do
    UPPER=`echo -n $WORD | tr '[:lower:]' '[:upper:]'`
    echo "$WORD, $SEQ" >>$GPF_FILENAME
    echo "#define TK_$UPPER $SEQ"
    SEQ=`expr $SEQ + 1`
done

gperf -t --language=ANSI-C --includes \
    --output-file=reservewords_res.h reservewords.gpf
